/*   1:    */ package org.intellij.lang.regexp.psi.impl;
/*   2:    */ 
/*   3:    */

import com.intellij.codeInsight.lookup.LookupValueFactory.LookupValueWithIcon;
import com.intellij.codeInsight.lookup.LookupValueWithPriority;
import com.intellij.codeInsight.lookup.LookupValueWithUIHint;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiReference;
import com.intellij.util.ArrayUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.PlatformIcons;
import org.intellij.lang.regexp.RegExpLanguageHosts;
import org.intellij.lang.regexp.RegExpTT;
import org.intellij.lang.regexp.psi.RegExpElementVisitor;
import org.intellij.lang.regexp.psi.RegExpProperty;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.awt.*;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */
/*  10:    */
/*  11:    */
/*  12:    */
/*  13:    */
/*  14:    */
/*  15:    */
/*  16:    */
/*  17:    */
/*  18:    */
/*  19:    */
/*  20:    */
/*  21:    */
/*  22:    */
/*  23:    */
/*  24:    */ 
/*  25:    */ public class RegExpPropertyImpl
/*  26:    */   extends RegExpElementImpl
/*  27:    */   implements RegExpProperty
/*  28:    */ {
/*  29:    */   private static final String[] e;
/*  30:    */   
/*  31:    */   public RegExpPropertyImpl(ASTNode paramASTNode)
/*  32:    */   {
/*  33: 43 */     super(paramASTNode);
/*  34:    */   }
/*  35:    */   
/*  36:    */   public PsiReference getReference()
/*  37:    */   {
/*  38: 47 */     ASTNode localASTNode = getNode().findChildByType(RegExpTT.LBRACE);
/*  39: 48 */     if (localASTNode == null) {
/*  40: 48 */       return null;
/*  41:    */     }
/*  42: 49 */     return new MyPsiReference(null);
/*  43:    */   }
/*  44:    */   
/*  45:    */   public boolean isNegated()
/*  46:    */   {
/*  47: 53 */     ASTNode localASTNode = getNode().findChildByType(RegExpTT.PROPERTY);
/*  48: 54 */     return (localASTNode != null) && (localASTNode.textContains('P'));
/*  49:    */   }
/*  50:    */   
/*  51:    */   @Nullable
/*  52:    */   public ASTNode getCategoryNode()
/*  53:    */   {
/*  54: 59 */     return getNode().findChildByType(RegExpTT.NAME);
/*  55:    */   }
/*  56:    */   
/*  57:    */   public void accept(RegExpElementVisitor paramRegExpElementVisitor)
/*  58:    */   {
/*  59: 63 */     paramRegExpElementVisitor.visitRegExpProperty(this);
/*  60:    */   }
/*  61:    */   
/*  62:    */   private class MyPsiReference
/*  63:    */     implements PsiReference
/*  64:    */   {
/*  65:    */     MyPsiReference(RegExpPropertyImpl.0 param0)
/*  66:    */     {
/*  67: 66 */       this();
/*  68:    */     }
/*  69:    */     
/*  70:    */     public PsiElement getElement()
/*  71:    */     {
/*  72: 68 */       return RegExpPropertyImpl.this;
/*  73:    */     }
/*  74:    */     
/*  75:    */     public TextRange getRangeInElement()
/*  76:    */     {
/*  77: 72 */       ASTNode localASTNode1 = RegExpPropertyImpl.this.getNode().findChildByType(RegExpTT.LBRACE);
/*  78: 73 */       assert (localASTNode1 != null);
/*  79: 74 */       ASTNode localASTNode2 = RegExpPropertyImpl.this.getNode().findChildByType(RegExpTT.RBRACE);
/*  80: 75 */       int i = localASTNode2 == null ? RegExpPropertyImpl.this.getTextRange().getEndOffset() : localASTNode2.getTextRange().getEndOffset() - 1;
/*  81:    */       
/*  82: 77 */       TextRange localTextRange = new TextRange(localASTNode1.getStartOffset() + 1, i);
/*  83: 78 */       return localTextRange.shiftRight(-RegExpPropertyImpl.this.getTextRange().getStartOffset());
/*  84:    */     }
/*  85:    */     
/*  86:    */     @Nullable
/*  87:    */     public PsiElement resolve()
/*  88:    */     {
/*  89: 83 */       return RegExpPropertyImpl.this;
/*  90:    */     }
/*  91:    */     
/*  92:    */     @NotNull
/*  93:    */     public String getCanonicalText()
/*  94:    */     {
/*  95: 88 */       String tmp16_13 = getRangeInElement().substring(getElement().getText());
/*  96: 88 */       if (tmp16_13 == null) {
/*  97: 88 */         throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/lang/regexp/psi/impl/RegExpPropertyImpl$MyPsiReference", "getCanonicalText" }));
/*  98:    */       }
/*  99: 88 */       return tmp16_13;
/* 100:    */     }
/* 101:    */     
/* 102:    */     public PsiElement handleElementRename(String paramString)
/* 103:    */       throws IncorrectOperationException
/* 104:    */     {
/* 105: 92 */       throw new IncorrectOperationException();
/* 106:    */     }
/* 107:    */     
/* 108:    */     public PsiElement bindToElement(@NotNull PsiElement paramPsiElement)
/* 109:    */       throws IncorrectOperationException
/* 110:    */     {
/* 111: 96 */       if (paramPsiElement == null) {
/* 112: 96 */         throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/lang/regexp/psi/impl/RegExpPropertyImpl$MyPsiReference", "bindToElement" }));
/* 113:    */       }
/* 114: 96 */       throw new IncorrectOperationException();
/* 115:    */     }
/* 116:    */     
/* 117:    */     public boolean isReferenceTo(PsiElement paramPsiElement)
/* 118:    */     {
/* 119:100 */       return false;
/* 120:    */     }
/* 121:    */     
/* 122:    */     @NotNull
/* 123:    */     public Object[] getVariants()
/* 124:    */     {
/* 125:105 */       ASTNode localASTNode = RegExpPropertyImpl.this.getCategoryNode();
/* 126:106 */       if ((localASTNode != null) && (localASTNode.getText().startsWith("In")) && (!localASTNode.getText().startsWith("Intelli")))
/* 127:    */       {
/* 128:107 */         String[] tmp43_40 = RegExpPropertyImpl.e;
/* 129:107 */         if (tmp43_40 == null) {
/* 130:107 */           throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/lang/regexp/psi/impl/RegExpPropertyImpl$MyPsiReference", "getVariants" }));
/* 131:    */         }
/* 132:107 */         return tmp43_40;
/* 133:    */       }
/* 134:109 */       String[][] arrayOfString = RegExpLanguageHosts.getInstance().getAllKnownProperties(getElement());
/* 135:110 */       Object[] arrayOfObject = new Object[arrayOfString.length];
/* 136:111 */       for (int i = 0; i < arrayOfObject.length; i++)
/* 137:    */       {
/* 138:112 */         String[] arrayOfString1 = arrayOfString[i];
/* 139:113 */         arrayOfObject[i] = new MyLookupValue(arrayOfString1);
/* 140:    */       }
/* 141:116 */       Object[] tmp132_131 = arrayOfObject;
/* 142:116 */       if (tmp132_131 == null) {
/* 143:116 */         throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/lang/regexp/psi/impl/RegExpPropertyImpl$MyPsiReference", "getVariants" }));
/* 144:    */       }
/* 145:116 */       return tmp132_131;
/* 146:    */     }
/* 147:    */     
/* 148:    */     public boolean isSoft()
/* 149:    */     {
/* 150:121 */       return true;
/* 151:    */     }
/* 152:    */     
/* 153:    */     private MyPsiReference() {}
/* 154:    */     
/* 155:    */     private class MyLookupValue
/* 156:    */       extends LookupValueFactory.LookupValueWithIcon
/* 157:    */       implements LookupValueWithPriority, LookupValueWithUIHint
/* 158:    */     {
/* 159:    */       private final String[] c;
/* 160:    */       
/* 161:    */       public MyLookupValue(String[] paramArrayOfString)
/* 162:    */       {
/* 163:128 */         super(PlatformIcons.PROPERTY_ICON);
/* 164:129 */         this.c = paramArrayOfString;
/* 165:    */       }
/* 166:    */       
/* 167:    */       public String getPresentation()
/* 168:    */       {
/* 169:133 */         ASTNode localASTNode = RegExpPropertyImpl.this.getCategoryNode();
/* 170:134 */         if ((localASTNode != null) && 
/* 171:135 */           (localASTNode.getText().startsWith("Is"))) {
/* 172:136 */           return "Is" + super.getPresentation();
/* 173:    */         }
/* 174:139 */         return super.getPresentation();
/* 175:    */       }
/* 176:    */       
/* 177:    */       public int getPriority()
/* 178:    */       {
/* 179:143 */         String str = this.c[0];
/* 180:144 */         if (str.equals("all")) {
/* 181:144 */           return 3;
/* 182:    */         }
/* 183:145 */         if (str.startsWith("java")) {
/* 184:145 */           return 1;
/* 185:    */         }
/* 186:146 */         return str.length() > 2 ? 2 : 0;
/* 187:    */       }
/* 188:    */       
/* 189:    */       public String getTypeHint()
/* 190:    */       {
/* 191:150 */         return "Character.is" + this.c[0].substring("java".length()) + "()";
/* 192:    */       }
/* 193:    */       
/* 194:    */       @Nullable
/* 195:    */       public Color getColorHint()
/* 196:    */       {
/* 197:155 */         return null;
/* 198:    */       }
/* 199:    */       
/* 200:    */       public boolean isBold()
/* 201:    */       {
/* 202:159 */         return false;
/* 203:    */       }
/* 204:    */     }
/* 205:    */   }
/* 206:    */   
/* 207:    */   static
/* 208:    */   {
/* 209:167 */     Field[] arrayOfField1 = Character.UnicodeBlock.class.getFields();
/* 210:168 */     ArrayList localArrayList = new ArrayList(arrayOfField1.length);
/* 211:169 */     for (Field localField : arrayOfField1) {
/* 212:170 */       if ((localField.getType().equals(Character.UnicodeBlock.class)) && 
/* 213:171 */         (Modifier.isStatic(localField.getModifiers())) && (Modifier.isFinal(localField.getModifiers()))) {
/* 214:172 */         localArrayList.add("In" + localField.getName());
/* 215:    */       }
/* 216:    */     }
/* 217:176 */     e = ArrayUtil.toStringArray(localArrayList);
/* 218:    */   }
/* 219:    */ }



/* Location:           E:\idea\

 * Qualified Name:     org.intellij.lang.regexp.psi.impl.RegExpPropertyImpl

 * JD-Core Version:    0.7.0.1

 */